var app = getApp();
Page({

  data: {
    url: '',
    userInfo: {},
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    appid: 'wx22d1466a657fcb78', 
    secret: '3d0813488feb2c4d67b320b9e0ae33aa', 
  },

  onLoad: function(options) {
    console.log("@@ options  options  ", options);
    // 正式地址--语音 助手
    let formalUrl = "https://eq.10jqka.com.cn/ai/webapp/miniprogramIndex.html?source=ths_weixin_xiaochengxu&footer=1&weixinprogram=1&preview=1&zzwp=1&place=shoujichaogu&miniprogram=1";
300
    // 预发布的地址--语音助手
     // formalUrl = 'http://prebots.iwencai.com/webapp/miniprogramIndex.html?source=ths_weixin_xiaochengxu&footer=1&weixinprogram=1&preview=1&zzwp=1&place=shoujichaogu&miniprogram=1'

    // 测试地址--语音助手
    // formalUrl = "https://testm.10jqka.com.cn/ai/webapp/miniprogramIndex.html?source=ths_weixin_xiaochengxu&footer=1&weixinprogram=1&preview=1&zzwp=1&place=shoujichaogu&miniprogram=1"

// 发布test
  //   formalUrl = "https://testm.10jqka.com.cn/devshouji/app/20190213/lyb_miniprogram_0213/lanyuanbiao_lyb_miniprogram_0213_1550046498733/miniprogramIndex.html?source=ths_weixin_xiaochengxu&footer=1&weixinprogram=1&preview=1&zzwp=1&place=shoujichaogu"
    
    let webviewUrl = 'https://eq.10jqka.com.cn/ai/webapp/miniprogramIndex.html?source=ths_weixin_xiaochengxu&footer=1&weixinprogram=1&preview=1&zzwp=1&place=shoujichaogu&miniprogram=1';
    if (options.scene) {
      const utilApi = require('../../utils/RequestUtil.js')
      utilApi('https://testm.10jqka.com.cn/mp/cache/question?since=' + options.scene).then(res => {
        console.log("@@ promise then: ", res)
        let scenceValue = res.data;
        webviewUrl = formalUrl + "&query=" + encodeURIComponent(decodeURIComponent(scenceValue));
        console.log("@@ scence path  ", webviewUrl)
        console.log("@@ 最后加载url:  ", webviewUrl);
        this.setData({
          url: webviewUrl
        })
      })
    } else {
      if (options.query) {
        webviewUrl = formalUrl + "&query=" + encodeURIComponent(decodeURIComponent(options.query));
      } else {
        webviewUrl = formalUrl;
      }
      console.log("@@ 最后加载url:  ", webviewUrl);
      this.setData({
        url: webviewUrl
      })
    }
    
  },


  onShow: function(pro) {
  },

  onReady: function(pro) {
  },

  onShareAppMessage: function(res) {
    return {
      title: '同花顺智能投顾',
      path: this.url
    }
  },


})